package com.base.service.impl;

import java.util.List;

import com.base.bean.Cardmake;
import com.base.service.CardmakeService;
import com.common.util.AbstractManager;
import com.common.util.PagerModel;

public class CardmakeServiceImpl extends AbstractManager implements
		CardmakeService {

	public void addCardmake(Cardmake cardmake) {
		String hql = "select nvl(max(makeno),0) from Cardmake ";
		
		long makeno = 0l;
		makeno = (Long) this.getHibernateTemplate().find(hql).get(0);
		makeno += 1l;
		
		cardmake.setMakeno(makeno);
		this.getHibernateTemplate().save(cardmake);
	}

	@SuppressWarnings("unchecked")
	public List<Cardmake> findAllCardmake() {
		String hql = "from Cardmake order by makeno";
		return this.getHibernateTemplate().find(hql);
	}

	public Cardmake findCardmake(long makeno) {
		return (Cardmake) this.getHibernateTemplate().load(Cardmake.class, makeno);
	}

	public PagerModel findCardmakeForPager() {
		String hql = "from Cardmake order by makeno";
		return searchPaginated(hql);
	}

	public void removeCardmake(long makeno) {
		Cardmake cardmake = null;
		cardmake = (Cardmake) this.getHibernateTemplate().load(Cardmake.class, makeno);
		if(cardmake != null) 
			this.getHibernateTemplate().delete(cardmake);
	}

	public void updateCardmake(Cardmake cardmake) {
		this.getHibernateTemplate().update(cardmake);
	}

}
